package com.xxxx.server.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author : ymd
 * @Date : 2020/10/21 0021 15:14
 * @Version 1.0
 * @Description : 消息中间件配置
 */
@Configuration
public class RabbitConfig {
    //定义短信队列
    @Bean
    public Queue queue1(){
        return new Queue("queue_msg");
    }
    //定义邮箱队列
    @Bean
    public Queue queue2(){
        return new Queue("queue_email");
    }
    //定义交换机
    @Bean
    public TopicExchange topicExchange(){
        return new TopicExchange("topicExchange");
    }
    //将队列绑定交换机
    @Bean
    public Binding binding1(){
        return BindingBuilder.bind(queue1()).to(topicExchange()).with("topic.msg");
    }
    @Bean
    public Binding binding2(){
        return BindingBuilder.bind(queue2()).to(topicExchange()).with("topic.email");
    }
}
